import GLib from 'gi://GLib';
import GnomeDesktop from 'gi://GnomeDesktop';
-import * as Main from '../ui/main.js';
-
export const DEFAULT_LOCALE = 'en_US';
export const DEFAULT_LAYOUT = 'us';
export const DEFAULT_VARIANT = '';
return _keyboardManager;
}
-export function releaseKeyboard() {
- if (Main.modalCount > 0)
- global.backend.unfreeze_keyboard(global.get_current_time());
- else
- global.backend.ungrab_keyboard(global.get_current_time());
-}
-
-export function holdKeyboard() {
- global.backend.freeze_keyboard(global.get_current_time());
-}
-
class KeyboardManager {
constructor() {
// The XKB protocol doesn't allow for more than 4 layouts in a
_modifiersSwitcher() {
const sourceIndexes = Object.keys(this._inputSources);
- if (sourceIndexes.length === 0) {
- KeyboardManager.releaseKeyboard();
+ if (sourceIndexes.length === 0)
return true;
- }
let is = this._currentSource;
if (!is)
}
activateInputSource(is, interactive) {
- // The focus changes during holdKeyboard/releaseKeyboard may trick
- // the client into hiding UI containing the currently focused entry.
- // So holdKeyboard/releaseKeyboard are not called when
- // 'set-content-type' signal is received.
- // E.g. Focusing on a password entry in a popup in Xorg Firefox
- // will emit 'set-content-type' signal.
- // https://gitlab.gnome.org/GNOME/gnome-shell/issues/391
- const holdKeyboard = !this._reloading;
- if (holdKeyboard)
- KeyboardManager.holdKeyboard();
this._keyboardManager.apply(is.xkbId);
let engine;
engine = `xkb:${name}:${variant}:${lang}`;
}
- this._ibusManager.setEngine(engine).then(() => {
- if (holdKeyboard)
- KeyboardManager.releaseKeyboard();
- });
+ this._ibusManager.setEngine(engine);
this._currentInputSourceChanged(is);